     package dao.impl;

import dao.DeptDao;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import pojo.Dept;
import utils.MyBatisUtil;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

public class DeptDaoImpl implements DeptDao {

    @Override
    public List<Dept> findAll() {
        //引入mybatis配置文件

       
       /* String resources="mybatis-config.xml";
        SqlSession sqlSession=null;

        try {
            InputStream inputStream = Resources.getResourceAsStream(resources);
            SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
            sqlSession= sqlSessionFactory.openSession();
            List<Dept> depts = sqlSession.getMapper(DeptDao.class).findAll();
            return depts;
        } catch (IOException e) {
            throw new RuntimeException(e);
        }finally {
            if (sqlSession!=null) {
                sqlSession.close();
            }*/
        // }


        // }

        return MyBatisUtil.getSession().getMapper(DeptDao.class).findAll();

    }
}
